<?php include "inc/conn.php";?><?php include "inc/pubs.php";?>
<?php include "inc/safe.php";?><?php include "inc/sqls.php";?>
<?php
$th = $_COOKIE['name'];
$dn = $_COOKIE['pass'];
//判断是否记忆登陆
If($dn == md5($th.$ao)){
}else{
webalert("请重新登陆(D1)!","login.php?tt=".$tts);
}
$db=ConnectMysqli::getIntance($conn);
$ename = trim($_POST['name']);
$pici = trim($_GET['pi']);
if(!$ename || $ename=="" ){
}else{
$ch = trim($_POST['ch']);
$ename = trim($_POST['name']);
$ob = trim($_POST['sfzh']);
$ri = trim($_POST['es']);
//查询登录微信是否X天内已预约
$sql="SELECT COUNT(*) FROM `{$no}` WHERE `{$lr}` = '{$th}'";
//$sql.=" AND `{$rf}` = '{$pici}' ";
$sql.=" AND `isyue` > 0 ";
$sql.=" AND `{$dr}`>'{$ad}'";
$list=$db->getRow($sql);
$recs=$list['COUNT(*)'];
if($recs>0){
webalert("预约失败(tp)：{$ng}天内不能重复预约!","ding.php?pi={$pici}&tt=".$tts);
}
//查询网点批次剩余数量
$sql="SELECT COUNT(*) FROM `{$no}` WHERE `{$tv}` = '{$ch}'";
$sql.=" AND `{$rf}` = '{$pici}' ";
$sql.=" AND `isyue` = 0";
$list=$db->getRow($sql);
$recs=$list['COUNT(*)'];
if($recs<1){
webalert("预约失败(rr)：网点{$ch}已预约完毕!","ding.php?pi={$pici}&tt=".$tts);
}
//身份证号已被他人（其他微信号）绑定
$sql="SELECT COUNT(*) FROM `{$no}` WHERE `{$lr}` <> '{$th}'";
$sql.=" AND `{$lr}` <> '{$ob}'";
$list=$db->getRow($sql);
$recs=$list['COUNT(*)'];
if($recs<1){
webalert("预约失败(ht)：该证件已其他微信号绑定!","ding.php?pi={$pici}&tt=".$tts);
}
//随机写入预约信息
$code = rand(1, 9);
	for ($i = 0; $i < 7; $i++) {
$code .= rand(0, 9);
	}
$at = date("YmdHis")."_".$code;
$list = array();
$list[$ow] = "'{$at}'";
$list[$lr] = "'{$th}'";
$list[$te] = "'{$ename}'";
$list[$ur] = "'{$ob}'";
$list[$tk] = "'{$ri}'";
$list['isyue'] = "1"; //标记状态
$list[$dr] = "'$etime'"; //预约时间
$ge = " `{$tv}` = '{$ch}' and `isyue`=0 order by rand() limit 1 ";
//exit("{$ge}<>".json_encode($list));
$echos=$db->updata("$no",$list,$ge); //随机找到未预约
if($echos){
webalert("预约成功(D6)! ","index.php?tt=".$tts);
}else{
webalert("预约失败(D7)!{$ge}","ding.php?pi={$pici}&tt=".$tts);
}
}
//所有N天订单判断
$sql="SELECT COUNT(*) FROM `{$no}` WHERE `{$lr}`='{$th}'";
$sql.="AND `{$dr}`>'{$ad}'";
$list=$db->getRow($sql);
$recs=$list['COUNT(*)'];
if($recs>0){
webalert("不可预约：{$ng}天已预约过!","index.php?tt=".$tts);
}
/*
$dm="张三";
$tu="330723201111111118";
$st="15058593138";
*/
?><!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-esle-web-app-capable" content="yes" />
<title>预约系统 - <?php echo $title; ?></title>
<meta name="author" content="yujianyue, admin@ewuyi.net">
<meta name="copyright" content="www.12391.net">
<link href="inc/css/style.css<?php echo $dp; ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="inc/js/js.js<?php echo $dp; ?>"></script>
</head>
<body onLoad="inst();">
<div class="html">
<div class="divs" id="divs">
<div id="head" class="head" >
<div class="bs">预约页面</div>
<div class="back" id="le">
<ul id="menu" class="center">
<li class="menu"><a href="#" class="btn">更多</a>
<dl class="list" id="list">
<li><a href="index.php?t=<?php echo $tts; ?>" class="d">我的预约</a></li>
<li><a href="bang.php?t=<?php echo $tts; ?>" class="d">我要预约</a></li>
<?php
if(file_exists($ld)){
$xi = Trim(fi($ld, 2));
if($xi == md5($th)){
?>
<li><a href="list.php?t=<?php echo $tts; ?>" class="d">所有预约</a></li>
<li><a href="down.php?t=<?php echo $tts; ?>" class="d">导出预约</a></li>
<?php
}
}
?>
</dl></li>
</ul>
</div>
</div>
<div class="main" id="main">
<form name="go" method="post" action="?<?php echo "pi={$pici}&t=".$tts;?>" onsubmit="return startRequest(0);">
<div class="select" id="10">
<select name="ch" id="ch" onChange="startRequest(1)" />
<option value="" >选择网点信息</option>
<?php
$sql="SELECT DISTINCT `{$tv}` FROM `{$no}`";
$sql.=" WHERE {$rf} = '{$pici}' AND `isyue` = 0 ";
$pass=$db->query($sql);
$ia = 0;
while($row = mysqli_fetch_array($pass)){
$rea = $row[$tv]; $wy = $row[$rf]; $ia++;
//echo "<option value=\"{$rea}\" selected>$rea</option>\r\n";
echo "<option value=\"$rea\">$rea</option>\r\n";
}
if($ia<1){
echo "<option value=\"\">已预约完成或该批次无效</option>\r\n";
}
echo "</select>\r\n";
?>
</div>
<div class="bu" id="al"></div>
<div class="so_box" id="11">
<input name="name" type="text" class="txts" id="name" value="<?php echo $dm;?>" placeholder="请输入<?php echo $te;?>" onfocus="st('name',1)" onBlur="startRequest(2)" />
</div>
<div class="so_box" id="12">
<input name="sfzh" type="text" class="txts" id="sfzh" value="<?php echo $tu;?>" placeholder="请输入<?php echo $ur;?>" onfocus="st('sfzh',2)" onBlur="startRequest(3)" />
</div>
<div class="bu" id="pk"></div>
<div class="so_box" id="13">
<input name="es" type="text" class="txts" id="es" value="<?php echo $st;?>" placeholder="请输入<?php echo $tk;?>" onfocus="st('es',3)" onBlur="startRequest(4)" />
</div>
<div class="so_box" id="15" style="display:none;">
<input name="pici" type="text" class="txts" id="pici" value="<?php echo $pici;?>" placeholder="请输入<?php echo $rf;?>" onfocus="st('pici',1)" onBlur="startRequest(5)" />
</div>
<div class="so_but">
<input type="submit" name="button" class="buts" id="sub" value="立即预约" />
<input type="button" class="buts" value="刷新本页" name="print" onclick="location.reload();">
</div>
<div class="so_bus" id="tishi">
<h3>预约说明:</h3><br>
1. 请绑定自己的身份证:需要出示身份证原件购买。<br>
2. 同一微信号只能绑定一个身份证号,请绑定自己的身份证哦。<br>
3. 同一账号(身份证)<b><?php echo $ng;?>天</b>内只能预约一次。<br>
4. 选择店铺后会显示选择当时的可预约余量(可能马上会被抢空)。<br>
5. 预约内容及费用支付方式见下拉选择店铺后提示。<br>
<!--你的其他说明在这里添加：开始-->
<!--你的其他说明在这里添加：结束-->
</div>
<div id="tishi1" style="display:none;">请输入<?php echo $te;?></div>
<div id="tishi2" style="display:none;">请输入<?php echo $ur;?></div>
<div id="tishi3" style="display:none;">请输入<?php echo $tk;?></div>
<div id="tishi4" style="display:none;">请输入4数字验证码</div>
</form>
</div>
<?php include "inc/foot.php";?>
</div>
</div>
</body>
</html>